Skip to content

fix: properly pass client API keys to AI providers#27

Merged
homanp merged 1 commit intomainfrom
fix/provider-api-keys
Mar 16, 2026
Merged

fix: properly pass client API keys to AI providers#27
homanp merged 1 commit intomainfrom
fix/provider-api-keys

Conversation

@homanp
Copy link
Copy Markdown
Owner

@homanp homanp commented Mar 16, 2026

Summary

  • Uses provider factory functions (createAnthropic, createOpenAI, etc.) instead of pre-configured default instances
  • Client-provided API keys are now correctly passed when creating provider instances
  • Previously, keys were passed as model-level settings and silently ignored — the providers only read from env vars

This fixes the AI_LoadAPIKeyError seen when deploying without server-side env vars (e.g. on a Droplet), where the app relies entirely on client-provided keys from localStorage.

Test plan

  • Existing create-model.test.ts tests pass
  • Lint and typecheck pass via pre-commit hooks
  • Verify on deployed Droplet: select a model, paste API key in UI, send a message — should work without ANTHROPIC_API_KEY env var

Use provider factory functions (createAnthropic, createOpenAI, etc.)
instead of pre-configured instances so client-provided API keys are
actually used. Previously keys were passed as model settings and ignored.
@github-actions github-actions bot added the contributor:verified Contributor passed trust analysis. label Mar 16, 2026
@homanp homanp self-assigned this Mar 16, 2026
@homanp
Copy link
Copy Markdown
Owner Author

homanp commented Mar 16, 2026

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@homanp homanp merged commit 8af67f7 into main Mar 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:verified Contributor passed trust analysis.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant